<div id="content_right" style="padding-left:20px">
  <?php 		

    	include_once("../../coms/xl_tintuc.php");
		if(isset($_REQUEST["query"]))
		{
			$ma_tt = $_REQUEST["ma"];		
			$layhinhanh = new xl_tintuc();
			$arr = $layhinhanh->Load_theo_matt($ma_tt);
			$hinhanh = $arr['hinhanh'];
			if($hinhanh !="")
				unlink("../../Images/Tintuc/".$hinhanh."");
			$xoa_tt = new xl_tintuc();
			$query = $xoa_tt->Xoa_tintuc($ma_tt);
		}	
		$tt = new xl_tintuc();
		$arr_tt = $tt->LoadAll();		
?>

 
	<div class="content_left_title">
        Quản lý tin tức
    </div>


    <div class="content_right_group_admin box_shadow" style="min-height:655px;">

    	<table width="98%" border="1" style="margin:10px 20px 10px 10px; line-height:25px; border-color:#993300" cellspacing="0"  bordercolor="#993300" >

        	<tr class="tieude_table">

                <td>Tiêu đề tin</td>

                <td>Ngày tạo</td>

                <td>Ngày đăng</td>

                <td>Người dùng gần nhất</td>

                <td>Chức năng</td>

            </tr>

            <?php

				$dem = 0;

				$start = 1;

				$limit = 18;

				$count = count($arr_tt);

				$pages = $count % $limit == 0 ? $count / $limit : ceil($count / $limit);

				if(isset($_GET["page"]))

					$start = ($_GET["page"] - 1) * $limit + 1;

				$end = ($start + $limit) < $count ? $start + $limit : $count + 1;

				for($i = $start ; $i < $end; $i++)

            	//for($i=0;$i<count($arr_sp); $i++)

				{

					$row = $arr_tt[$i-1];

					if($i % 2 == 1)

						echo '<tr bgcolor="#FFCC99" style="color:#000000">';

					else

						echo '<tr>';

					if($i % 2 == 1)

						echo '<td style="padding-left:10px;" class="chucnang1">';

					else

						echo '<td style="padding-left:10px;" class="chucnang">';

			?>



                	<a href="trangchu.php?key=sua&ma=<?php echo $row['matt'] ?>"><?php echo $row['tieude'] ?></a>

                </td>

                <td align="center"><?php echo $row['ngaytao'] ?></td>

                <td align="center"><?php echo $row['ngaydang'] ?></td>

                <td align="center"><?php echo $row['manguoidung'] ?></td>

            <?php

				if($i % 2 == 1)

                	echo '<td align="center" class="chucnang1">';

				else

					echo '<td align="center" class="chucnang">';

			?>

            		<a href="trangchu.php?key=tt&query=del&ma=<?php echo $row['matintuc'] ?>"onClick=" return confirm('Bạn có thật sự muốn xóa tin này?')">Xóa</a> | <a href="trangchu.php?key=tt&matt=<?php echo $row['matintuc'] ?>"> Sửa</a></td>

            </tr>	

            <?php

            	}

			?>

        </table>

      <div class="phantrang">

      	<?php

			$self = $_SERVER["PHP_SELF"];

			if(isset($_GET["page"]))

				$page = $_GET["page"];

			$page_list = "";

			for($i=1; $i <= $pages; $i++)

			{

				$page_list .= "&nbsp;[&nbsp;<a href='$self?page=$i&key=tt'>";

				if(isset($_GET["page"]))

				{

					if($page == $i)

						$page_list .= "<span style='font-size:1.1em; color:#fcf46f'><b>$i</b></span></a>&nbsp;]&nbsp;";

					else

						$page_list .= "$i</a>&nbsp;]&nbsp;";

				}

				else

					$page_list .= "$i</a>&nbsp;]&nbsp;";

			}

			echo $page_list;

		?>

      </div>

      <div style="margin-left:10px;" align="center"> 

                	<input type="button" name="bt_taomoi" value="Tạo mới"  

                    	onClick="javascript:window.location='trangchu.php?key=themtintuc'" class="button small blue"/> 

      </div> 

 

  </div>

</div>

